import router from "@/router/routes.js";
import util from "@/libs/util.js";
import * as CryptoJS from "crypto-js";
import storage from "@/utils/storage";
import * as HttpServices from "@/utils/HttpServices";
import { getPayload, getLoginPayload } from "@/utils/server";
import { binterface } from "@/utils";
import { Message, MessageBox } from "element-ui";
import { ddmg_config } from "@/utils/appConfig";
import dayjs from "dayjs";

export default {
  moduleName: "account",
  namespaced: true,
  state: {
    heartBeatTimer: null, //心跳计时器
    // 登录倒计时操作
    loginCount: 0, //登录获取验证码倒计时
    showLoginCode: false, //登录是否显示倒计时按钮
    loginTimer: null, //登录倒计时定时器
    // 忘记密码操作
    forgetCount: 0, //登录获取验证码倒计时
    showForgetCode: false, //登录是否显示倒计时按钮
    forgetTimer: null, //登录倒计时定时器
    logining: false, //登录状态
    menuTree: storage.getStorage("menuTree") || [],
    currentMode: storage.getStorage("hanhe_currentMode") || 0, //0表示普通业务系统模式，1，表示经理人工作台
    systems: storage.getStorage("systems") || [],
    currentSystemID: storage.getStorage("currentSystemID") || null,
    menuAuth: storage.getStorage("menuAuth") || [],
    menuNameList: storage.getStorage("menuNameList") || {},
    userInfo: storage.getStorage('userInfo') || ""
  },
  mutations: {
    SET_USER_INFO: (state, data) => {
      state.userInfo = data;
      storage.setStorage("userInfo", data);
    },
    SET_MENU_Name: (state, data) => {
      state.menuNameList = data;
      storage.setStorage("menuNameList", data);
    },
    SET_MENU_Auth: (state, data) => {
      state.menuAuth = data;
      storage.setStorage("menuAuth", data);
    },
    SET_MENU_TREE: (state, menus) => {
      const data = binterface(menus);
      storage.setStorage("menuTree", data.menuTree);
      state.menuTree = data.menuTree;
    },
    setCurrentMode: (state, payload) => {
      state.currentMode = payload;
      storage.setStorage("hanhe_currentMode", payload);
    },
    setSubSystems: (state, payload) => {
      state.systems = payload;
      storage.setStorage("systems", payload);
    },
    setCurrentSystemID: (state, payload) => {
      console.log("setcurrentSystemID=", payload);
      state.currentSystemID = payload;
      storage.setStorage("currentSystemID", payload);
    },
    setLoginTimer(state) {
      //点击获取验证码
      const TIME_COUNT = 60; //倒计时60秒
      if (!state.loginTimer) {
        state.loginCount = TIME_COUNT;
        state.showLoginCode = true;
        state.loginTimer = setInterval(() => {
          if (state.loginCount > 0 && state.loginCount <= TIME_COUNT) {
            state.loginCount--;
          } else {
            state.showLoginCode = false;
            clearInterval(state.loginTimer);
            state.loginTimer = null;
          }
        }, 1000);
      }
    },
    setForgetTimer(state) {
      //点击获取验证码
      const TIME_COUNT = 60; //倒计时60秒
      if (!state.forgetTimer) {
        state.forgetCount = TIME_COUNT;
        state.showForgetCode = true;
        state.forgetTimer = setInterval(() => {
          if (state.forgetCount > 0 && state.forgetCount <= TIME_COUNT) {
            state.forgetCount--;
          } else {
            state.showForgetCode = false;
            clearInterval(state.forgetTimer);
            state.forgetTimer = null;
          }
        }, 1000);
      }
    },
    clearForgetTimer(state) {
      state.showForgetCode = false;
      clearInterval(state.forgetTimer);
      state.forgetTimer = null;
    },
    // 开始心跳  10分钟请求一次心跳接口
    startHeartBeatTask(state) {
      // const token = util.cookies.get("token");
      return; //暂停token，后端有做2个小时失效，中间有请求接口会自动延时token有效期；
      const token = storage.getStorage("token");
      if (token && token !== "undefined") {
        state.heartBeatTimer = setInterval(() => {
          console.log("start heart beat ");
          const payload = getLoginPayload("api900103", { v: "1" });
          HttpServices.startApiReq(payload);
        }, 1000 * 60 * 10);
      }
    },
    // 停止心跳任务
    stopHeartBeatTask(state) {
      if (state.heartBeatTimer) {
        clearInterval(state.heartBeatTimer);
        state.heartBeatTimer = null;
      }
    }
  },
  actions: {
    /**
     * @description 注销账号
     * @param {*} param0 
     * @param {*} params 
     */
    logoff({state,dispatch,commit},params){
      return new Promise(async (resolve,reject)=>{
        const payload = getLoginPayload("fin900104", params);
        state.logining = true;
        HttpServices.startApiReq(payload).then(res=>{
          if(res.msgcode == 1){
            Message({
              type: 'success',
              message: '账号已注销!'
            });
            resolve(res.resultdata)
          }else{
            reject(res.message)
          }
          state.logining = false
        })
      })
    },
    /**
     * @description 登录
     * @param {Object} context
     * @param {Object} payload username {String} 用户账号
     * @param {Object} payload password {String} 密码
     * @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
     */
    async login({ state, dispatch, commit }, params) {
      console.log("params", params);
      let messageInfo = "";
      try {
        let res = {};
        let data = {};
        if (params.fromOther && params.fromOther == true) {
          // 从其他系统登录成功后，跳转到本系统，直接登录成功；无须再让用户输入账号、密码；
          res.msgcode = 1;
          let loginInfoObj = {};
          try {
            const loginInfoString = util.cookies.getByPureKey(
              "ddmg_hanhe_logininfo"
            );
            loginInfoObj = JSON.parse(loginInfoString);
          } catch (err) {
            console.log("获取其他平台登录信息失败");
          }
          data.logininfo = loginInfoObj;
          data.roleinfo = loginInfoObj.roleinfo;
        } else {
          // 本系统登录页面登录
          const transCode = "fin900101";
          // 账号密码登录
          params.loginpwd = params.loginpwd
            ? CryptoJS.MD5("KKun&" + params.loginpwd).toString()
            : ""; // 登录密码md5加密
          // 随机码登录
          params.RandomCode = params.RandomCode
            ? CryptoJS.MD5("KKun&" + params.RandomCode).toString()
            : ""; // 登录密码md5加密
          const payload = getPayload(transCode, params);
          state.logining = true;
          // 一、登录；
          res = await HttpServices.startApiReq(payload);
          if (res.msgcode == 1) {
            data = res.resultdata;
          }
        }
        if (res.msgcode == 1) {
          // 设置 cookie 一定要存 uuid 和 token 两个  cookie
          // 整个系统依赖这两个数据进行校验和存储
          // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
          // token 代表用户当前登录状态 建议在网络请求中携带 token
          // 如有必要 token 需要定时更新，默认保存一天
          const userInfo = data.logininfo;
          commit("SET_USER_INFO",data.logininfo)
          // userInfo.lastlogintime = data.roleinfo?.lastlogintime;
          // userInfo.usermobilenum = data.roleinfo?.usermobilenum;
          // userInfo.managertype = data.roleinfo?.managertype; //"managertype"  N表示不是经理人
          userInfo.name = userInfo.username;
          let { rsa_pub, uid, keys, userid } = userInfo;
          const domain = window.location.domain;
          // util.cookies.set("uuid", userid, {
          //   expires: expiresTime,
          //   domain,
          //   path: "/"
          // });
          const currentTime = new Date().getTime();
          let expiresTime = new Date(currentTime + 1000 * 60 * 120); // 2小时后过期
          // console.log("expiresTime ==", expiresTime, currentTime);
          util.cookies.set("token", uid, {
            expires: expiresTime,
            domain,
            path: "/"
          });
          storage.setStorage("uuid", userid);
          storage.setStorage("token", uid);
          storage.setStorage("opdate", dayjs());
          storage.setStorage("kkun_uid", uid);
          storage.setStorage("kkun_keys", keys);
          storage.setStorage("rsa_pub", rsa_pub);
          storage.setStorage("loginid", params.loginid);

          // 二、登录成功后，先获取平台子系统列表
          const subsPayload = getLoginPayload("fin007004", {}, false);
          const subSystemInfoRes = await HttpServices.startApiReq(subsPayload);
          if (subSystemInfoRes.msgcode == 1) {
            // 获取到子系统后，只筛选需要的系统：汉河版业务系统、汉河版运营系统、汉河版经理人工作台
            if (subSystemInfoRes.resultdata) {
              const subSystems = subSystemInfoRes.resultdata
              commit("SET_MENU_TREE", subSystems.menu);
              // const subSystems = subSystemInfoRes.resultdata.filter(item => {
              //   return item.ID == "8888" || item.ID == "8900";
              // });
              // if (subSystems && subSystems.length > 0) {
              //   const systemObj = subSystems[0];
              //   // 三、获取第一个子系统的路由菜单权限、缓存本地
              //   const systemPayload = getLoginPayload(
              //     "use801997",
              //     {
              //       SystemID: systemObj.ID
              //     },
              //     false
              //   );
              //   const systemRouterRes = await HttpServices.startApiReq(
              //     systemPayload
              //   );
              //   if (systemRouterRes.msgcode == 1) {
              //     commit("setSubSystems", subSystems);
              //     commit("setCurrentSystemID", systemObj.ID);
              //     userInfo.enterprises = systemRouterRes.resultdata.Orgs;
              //     // 设置 vuex 用户信息
              //     await dispatch("d2admin/user/set", userInfo, { root: true });
              //     await dispatch("storageMenus", {
              //       systemID: systemObj.ID,
              //       menus: systemRouterRes.resultdata.Menu
              //     });
              //     // 用户登录后从持久化数据加载一系列的设置
              //     await dispatch("load");
              //   } else {
              //     // 没有配置菜单权限，提示联系管理员配置相关菜单权限
              //     messageInfo =
              //       "没有配置菜单权限，请联系管理员配置相关菜单权限";
              //     await dispatch("clear");
              //   }
              //   return systemRouterRes;
              // } else {
              //   // 没有系统权限，请联系管理员配置相关系统权限
              //   messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
              //   await dispatch("clear");
              // }
            } else {
              // 没有系统权限，请联系管理员配置相关系统权限
              messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
              await dispatch("clear");
            }
          } else {
            // 没有系统权限，请联系管理员配置相关系统权限
            // 获取菜单权限信息失败，删除登录信息，重新登录；
            messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
            await dispatch("clear");
          }
          return subSystemInfoRes;
        } else {
          await dispatch("clear");
          return res;
        }
      } finally {
        if (messageInfo) {
          Message({
            type: "error",
            showClose: true,
            message: messageInfo
          });
        }
        state.logining = false;
      }
    },
    async getSystemMenuInfo({ commit, dispatch, rootGetters }, SystemID) {
      const systemPayload = getLoginPayload(
        "use801997",
        {
          SystemID: SystemID
        },
        false
      );
      const systemRouterRes = await HttpServices.startApiReq(systemPayload);
      console.log("systemRouterRes=", systemRouterRes);
      if (systemRouterRes.msgcode == 1) {
        await dispatch("storageMenus", {
          systemID: SystemID,
          menus: systemRouterRes.resultdata.Menu
        });
        // 用户登录后从持久化数据加载一系列的设置
        const userInfo = rootGetters.userInfo;
        userInfo.enterprises = systemRouterRes.resultdata.Orgs;
        // 设置 vuex 用户信息
        await dispatch("d2admin/user/set", userInfo, { root: true });
        return systemRouterRes;
      } else {
        return systemRouterRes;
      }
    },

    // 验证密码有效期
    async checkPwdValidity({ commit, dispatch }, params) {
      console.log("1111-checkPwdValidity");
      const payload = getLoginPayload("xyh102008", params);
      console.log("1111-checkPwdValidity", payload);
      const res = await HttpServices.startApiReq(payload);
      console.log("1111-res", res);
      return res;
    },

    // 修改密码
    async modifyPwd({ commit, dispatch }, params) {
      const payload = getLoginPayload("use801999", params);
      const res = await HttpServices.startApiReq(payload);
      if (res.code == 1) {
      }
    },
    // // 忘记密码
    // async forgetPwd({ commit, dispatch }, params) {
    //   const payload = getPayload("use801999", params);
    //   const res = await HttpServices.startApiReq(payload);
    //   if (res.msgcode == 1) {
    //   }
    // },
    // 发送验证码
    async sendCode({ commit, dispatch }, { username = "" } = {}) {
      const payload = getPayload("use801999", { phone: username });
      const res = await HttpServices.startApiReq(payload);
      if (res.msgcode == 1) {
        commit("setLoginTimer");
      }
    },

    // 忘记密码
    async forgetPwd({ commit, dispatch, state }, data) {
      let params = {
        MobilePhone: data.MobilePhone,
        SMSCode: data.SMSCode,
        NewPassword: CryptoJS.MD5("KKun&" + data.NewPassword).toString(),
        SystemID: state.currentSystemID
      };
      console.log("##forgetPwd00=>", params);
      const payload = getPayload("use002003", params);
      const res = await HttpServices.startApiReq(payload);
      if (res.msgcode == 1) {
        return res;
      }
    },

    async editPwd({ commit, dispatch, state }, data) {
      let params = {
        OldPassword: CryptoJS.MD5("KKun&" + data.oldPwd).toString(),
        NewPassword: CryptoJS.MD5("KKun&" + data.pass).toString()
      };
      console.log("##editPwd00=>", params);
      const payload = getLoginPayload("use804001", params);
      const res = await HttpServices.startApiReq(payload);
      return res;
      console.log("##editPwd11=>", res);
    },

    async sendForgetCode({ commit, dispatch, state }, username) {
      console.log("##sendForgetCode00=>", username);
      let params = {
        MobilePhone: username,
        SystemID: 8888, //从未登录时，用户没选择过系统，直接取state中的系统id可能会不存在，汉河端重置密码统一使用业务端系统id
        SMSType: 2 // 手动验证码走2
      };
      const payload = getPayload("use002001", params);
      const res = await HttpServices.startApiReq(payload);
      if (res.msgcode == 1) {
        commit("setForgetTimer");
      }
    },
    clearForgetTimer({ commit }) {
      commit("clearForgetTimer");
    },
    async storageMenus({ state, commit, dispatch, rootGetters }, data) {
      const systemID = data.systemID;
      const menus = data.menus;
      // if (systemID == "8888" && rootGetters.userInfo.managertype != "N") {
      //   // 业务系统、且为经理人时，可切换模式
      //   // 将obj中的业务工作台、管理工作台菜单取出来用作切换模式数据
      //   const storageMenus = menus.filter(menu => {
      //     return (
      //       // menu.MenuName == "经理人业务工作台" ||
      //       menu.MenuName != "经理人管理工作台"
      //     );
      //   });
      //   // commit("setCurrentMode", 1); // 默认设置经理人工作台
      //   commit("SET_MENU_TREE", storageMenus);
      //   // commit("setAllMenuTree", menus);
      //   // await dispatch("d2admin/menu/asideCollapseSet", true); // 经理人工作台默认收起侧边栏
      // } else {
      //   const storageMenus = menus.filter(menu => {
      //     return (
      //       menu.MenuName != "经理人业务工作台" &&
      //       menu.MenuName != "经理人管理工作台"
      //     );
      //   });
      //   commit("SET_MENU_TREE", storageMenus);
      // }
      let menusButtons = [];
      let menusNames = {};
      function findButtions(data) {
        data.forEach(item => {
          if (item.MenuCode && item.MenuName) {
            menusNames[item.MenuCode] = item.MenuName;
          }
          if (item.Buttons && item.Buttons.length > 0) {
            menusButtons = [...menusButtons, ...item.Buttons];
          }
          if (item.children && item.children.length > 0) {
            findButtions(item.children);
          }
        });
      }
      let menusAllButtons = [];
      function findChildBtn(data) {
        data.forEach(item => {
          if (item.children && item.children.length > 0) {
            menusAllButtons = [...menusAllButtons, ...item.children];
            if (
              item.children?.children &&
              item.children?.children?.length > 0
            ) {
              findChildBtn(item.children.children);
            }
          }
        });
      }

      findButtions(menus);
      findChildBtn(menusButtons);
      commit("SET_MENU_Auth", menusAllButtons.concat(menusButtons));
      commit("SET_MENU_Name", menusNames);
      commit("SET_MENU_TREE", menus);
      return true;
    },
    async clear({ dispatch }) {
      // const domain = window.location.domain;
      // util.cookies.remove("token", {
      //   domain,
      //   path: "/"
      // });
      // util.cookies.remove("uuid", {
      //   domain,
      //   path: "/"
      // });
      util.cookies.remove("token");
      storage.removeStorage("uuid");
      storage.removeStorage("token");
      // 删除第三方跳转到汉河系统登录信息
      // util.cookies.removeByPureKey("ddmg_hanhe_logininfo", {
      //   domain: ".ddmg.com",
      //   path: "/"
      // });
      storage.removeStorage("kkun_uid");
      storage.removeStorage("kkun_keys");
      storage.removeStorage("rsa_pub");
      storage.removeStorage("loginid");
      // util.cookies.removeByPureKey("tomall_token", {
      //   domain: ".ddmg.com",
      //   path: "/"
      // });
      // util.cookies.removeByPureKey("tomall_uuid", {
      //   domain: ".ddmg.com",
      //   path: "/"
      // });
      // util.cookies.remove("is_get_login");
      // 清空 vuex 用户信息
      // const res = await dispatch("d2admin/user/set", {}, { root: true });
      // return res;
    },
    /**
     * @description 注销用户并返回登录页面
     * @param {Object} context
     * @param {Object} payload confirm {Boolean} 是否需要确认
     */
    logout({ commit, dispatch }, { confirm = false } = {}) {
      /**
       * @description 注销
       */
      async function logout() {
        // 删除cookie
        await dispatch("clear");
        commit("stopHeartBeatTask"); // ---网关升级，无须再使用心跳
        // 跳转路由
        // // 为解决线上js、css缓存问题，退出登录做一次刷新
        // if (process.env.NODE_ENV != "development") {
        //   window.location.href = `https://${
        //     document.domain
        //   }/#/login?re=${Math.random() * 1000}`;
        //   window.location.reload();
        // } else {
        //   router.push({ name: "login" });
        // }
        // router.replace({ name: "login" });
        window.location.reload();
      }
      // 判断是否需要确认
      if (confirm) {
        MessageBox.confirm("确定要注销当前用户吗", "注销用户", {
          type: "warning"
        }).then((res) => {
            dispatch('logoff',{})
            logout();
        }).catch(action => {
          console.log(action)
          Message({ message: "取消注销操作" });
        });
      } else {
        logout();
      }
    },
    /**
     * @description 用户登录后从持久化数据加载一系列的设置
     * @param {Object} context
     */
    async load({ dispatch, commit }) {
      console.log("account load");
      // 加载用户名
      await dispatch("d2admin/user/load", null, { root: true });
      // 加载主题
      await dispatch("d2admin/theme/load", null, { root: true });
      // 加载页面过渡效果设置
      await dispatch("d2admin/transition/load", null, { root: true });
      // 持久化数据加载上次退出时的多页列表
      await dispatch("d2admin/page/openedLoad", null, { root: true });
      // 持久化数据加载侧边栏配置
      await dispatch("d2admin/menu/asideLoad", null, { root: true });
      // 持久化数据加载全局尺寸
      await dispatch("d2admin/size/load", null, { root: true });
      // 持久化数据加载颜色设置
      await dispatch("d2admin/color/load", null, { root: true });
      // 登录成功后，需做心跳，保活token；---网关升级，无须再使用心跳
      commit("startHeartBeatTask");
    },

    async getLoginGuid({ }, params) {
      console.log(params, "params");
      const payload = getPayload("xyh520101", params);
      const res = await HttpServices.startApiReq(payload);
      return res;
    },
    async getLoginGuidStatus({ dispatch }, params) {
      console.log(params, "params");
      const payload = getPayload("xyh520102", params);
      const res = await HttpServices.startApiReq(payload);
      return res;
    },
    async guidLogin({ state, dispatch, commit }, params) {
      console.log("params", params);
      let messageInfo = "";
      try {
        let res = {};
        let data = {};
        const payload = getPayload("use520101", params);
        state.logining = true;
        // 一、登录；
        res = await HttpServices.startApiReq(payload);
        if (res.msgcode == 1) {
          data = res.resultdata;
          // 设置 cookie 一定要存 uuid 和 token 两个  cookie
          // 整个系统依赖这两个数据进行校验和存储
          // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
          // token 代表用户当前登录状态 建议在网络请求中携带 token
          // 如有必要 token 需要定时更新，默认保存一天
          const userInfo = data.logininfo;
          userInfo.lastlogintime = data.roleinfo?.lastlogintime;
          userInfo.usermobilenum = data.roleinfo?.usermobilenum;
          userInfo.managertype = data.roleinfo?.managertype; //"managertype"  N表示不是经理人
          userInfo.name = userInfo.username;
          let { rsa_pub, uid, keys, userid } = userInfo;
          // const domain = window.location.domain;
          // util.cookies.set("uuid", userid, {
          //   domain,
          //   path: "/"
          // });
          // const currentTime = new Date().getTime();
          // let expiresTime = new Date(currentTime + 1000 * 60 * 120); // 2小时后过期
          // console.log("expiresTime ==", expiresTime, currentTime);
          // util.cookies.set("token", uid, {
          //   expires: expiresTime,
          //   domain,
          //   path: "/"
          // });
          storage.setStorage("uuid", userid);
          storage.setStorage("token", uid);
          storage.setStorage("opdate", dayjs());
          storage.setStorage("kkun_uid", uid);
          storage.setStorage("kkun_keys", keys);
          storage.setStorage("rsa_pub", rsa_pub);
          storage.setStorage("loginid", params.loginid);

          // 二、登录成功后，先获取平台子系统列表
          const subsPayload = getLoginPayload("use801996", {}, false);
          console.log(subsPayload, "subsPayload");
          const subSystemInfoRes = await HttpServices.startApiReq(subsPayload);
          if (subSystemInfoRes.msgcode == 1) {
            // 获取到子系统后，只筛选需要的系统：汉河版业务系统、汉河版运营系统、汉河版经理人工作台
            if (subSystemInfoRes.resultdata) {
              const subSystems = subSystemInfoRes.resultdata.filter(item => {
                return item.ID == "8888" || item.ID == "8900";
              });
              if (subSystems && subSystems.length > 0) {
                const systemObj = subSystems[0];
                // 三、获取第一个子系统的路由菜单权限、缓存本地
                const systemPayload = getLoginPayload(
                  "use801997",
                  {
                    SystemID: systemObj.ID
                  },
                  false
                );
                const systemRouterRes = await HttpServices.startApiReq(
                  systemPayload
                );
                if (systemRouterRes.msgcode == 1) {
                  commit("setSubSystems", subSystems);
                  commit("setCurrentSystemID", systemObj.ID);
                  userInfo.enterprises = systemRouterRes.resultdata.Orgs;
                  // 设置 vuex 用户信息
                  await dispatch("d2admin/user/set", userInfo, { root: true });
                  await dispatch("storageMenus", {
                    systemID: systemObj.ID,
                    menus: systemRouterRes.resultdata.Menu
                  });
                  console.log("哈哈哈哈");
                  // 用户登录后从持久化数据加载一系列的设置
                  await dispatch("load");
                } else {
                  // 没有配置菜单权限，提示联系管理员配置相关菜单权限
                  messageInfo =
                    "没有配置菜单权限，请联系管理员配置相关菜单权限";
                  await dispatch("clear");
                }
                return systemRouterRes;
              } else {
                // 没有系统权限，请联系管理员配置相关系统权限
                messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
                await dispatch("clear");
              }
            } else {
              // 没有系统权限，请联系管理员配置相关系统权限
              messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
              await dispatch("clear");
            }
          } else {
            // 没有系统权限，请联系管理员配置相关系统权限
            // 获取菜单权限信息失败，删除登录信息，重新登录；
            messageInfo = "没有系统权限，请联系管理员配置相关系统权限";
            await dispatch("clear");
          }
          return subSystemInfoRes;
        } else {
          await dispatch("clear");
          return res;
        }
      } finally {
        if (messageInfo) {
          Message({
            type: "error",
            showClose: true,
            message: messageInfo
          });
        }
        state.logining = false;
      }
    }
  }
};
